package com.wr.hangzhounewlight.service.frontend;

import com.wr.hangzhounewlight.mapper.OutputMasterMapper;
import com.wr.hangzhounewlight.mapper.OutputSlaveMapper;
import com.wr.hangzhounewlight.obj.dto.frontend.OutputSelectDTO;
import com.wr.hangzhounewlight.obj.dto.frontend.R;
import com.wr.hangzhounewlight.obj.vo.frontend.OutputSelectVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yuanzhizhuo
 * createDate 2025/11/14
 */
@Service
public class OutputSelectService {

    private final OutputMasterMapper outputMasterMapper;
    private final OutputSlaveMapper outputSlaveMapper;

    public OutputSelectService(OutputMasterMapper outputMasterMapper, OutputSlaveMapper outputSlaveMapper) {
        this.outputMasterMapper = outputMasterMapper;
        this.outputSlaveMapper = outputSlaveMapper;
    }

    public R queryOutput(OutputSelectDTO dto) {
        List<OutputSelectVO> voList = outputMasterMapper.selectOutputVO(dto).stream().peek(vo ->
                vo.setOutputList(outputSlaveMapper.selectOutputVO(vo.getOutputMasterId()))
        ).toList();
        return new R(200, null, voList);
    }

}
